from handler.HandlerBase import HandlerBase
from pyHS100 import SmartPlug


class Pyhs(HandlerBase):
	def __init__(self, content):
		self.plug = SmartPlug(content['ip'])

	def change_state(self, from_state, to_state):
		if to_state.lower() == 'on':
			self.activate()
		elif to_state.lower() == 'off':
			self.deactivate()

	def activate(self):
		self.plug.state = "ON"

	def deactivate(self):
		self.plug.state = "OFF"
